Uec3.DepartmentQueryWindow = Ext.extend(Ext.app.Module, {
	id : 'serviceItems',
	type : 'common/serviceItems',

	/**
	 * Initialize this module. This function is called at startup (page
	 * load/refresh).
	 */

	getComponents : function(params) {

		var serviceItems_ds;
		var serviceItems_grid;

		var getAndRestoreDepartment = function() {

			var packageId = params.id;
			serviceItems_ds = new Ext.data.Store({
						// proxy: new Ext.data.MemoryProxy(myData),
						proxy : new Ext.data.HttpProxy({
									url : Uec3.App.Constants.homeUrl
											+ '/department/base!query.do'
								}),
						baseParams : {
							start : 0,
							limit : 10
						},
						reader : new Ext.data.JsonReader({
									totalProperty : 'totalProperty',
									root : 'root'
								}, [{
											name : 'id'
										},{
											name : 'code'
										}, {
											name : 'name'
										}

								]),
						remoteSort : true,

						// 默认排序字段
						sortInfo : {
							field : "id",
							direction : "asc"
						}

					});
		};

		var componentInitsDepartment = function() {

			var department_colModel = new Ext.grid.ColumnModel([
					new Ext.grid.RowNumberer(),
					{
						header : "ID",
						width : 80,
						dataIndex : 'id'
					}, {
						header : "服务编号",
						width : 100,
						dataIndex : 'code'
					}, {
						header : "服务名称",
						width : 80,
						sortable : true,
						dataIndex : 'name'
					}

			]);
			// create the Grid
			serviceItems_grid = new Ext.grid.GridPanel(

			{
						// title:'部门信息列表',
						region : 'center',
						iconCls : 'icon-grid',
						enableColumnMove : false,
						enableColumnMoveResize : false,
						stripeRows : true,
						height : 600,
						loadMask : {
							msg : "...加载数据中"
						},
						store : serviceItems_ds,
						columnLines : false,
						cm : department_colModel,
						sm : new Ext.grid.RowSelectionModel({
									singleSelect : true
								}),
						viewConfig : {
							forceFit : true,
							columnsText : '显示的列',
							scrollOffset : 20,
							sortAscText : '升序',
							sortDescText : '降序'
						},
						bbar : new Ext.PagingToolbar({
									pageSize : 10,
									store : serviceItems_ds,
									display : true,
									displayInfo : true,
									displayMsg : '第 {0} - {1} 条  共 {2} 条',
									emptyMsg : "没有记录",
									items : [/**
												 * '-', { pressed: true,
												 * enableToggle:true, text:
												 * 'Show Preview', cls:
												 * 'x-btn-text-icon details',
												 * toggleHandler: function(btn,
												 * pressed){ var view =
												 * department_grid.getView();
												 * view.showPreview = pressed;
												 * view.refresh(); } }
												 */
									]
								})

					});

			serviceItems_ds.load();

		};

		var controlDepartmentEvent = function() {

		};

		getAndRestoreDepartment();

		componentInitsDepartment();

		controlDepartmentEvent();

		return serviceItems_grid;

	},

	/**
	 * Create this modules window here.
	 */
	createWindow : function(params) {
		
		var windowId = 'loginHistory';
		if (params) {
			windowId += "_" + params.winId;
		}
		
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow(windowId);
		if (!win) {
			win = desktop.createWindow({
						id : windowId,
						title : '服务明细',
						width : 500,
						modal : true,
						height : 330,
						iconCls : 'acc-icon',
						shim : false,
						animCollapse : false,
						constrainHeader : true,
						maximizable : false,
						taskbuttonTooltip : "服务明细",
						resizable : false,
						layout : "fit",
						items : [this.getComponents(params)]
					});

		}
		win.show();

	}
});